<?php

namespace app\web\services;

use think\Service;
use think\facade\Request;
use app\web\model\ManualGroupModel;

/**
 * @手册分类管理
 */
class ManualGroupService extends Service
{
    protected $manualGroupModel;
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->manualGroupModel = new ManualGroupModel();
    }
    
    /**
     * @获取所有数据
     */
    public function getDataList($pid){
        $where=[['status','eq',1],['pid','eq',$pid]];
        $ruslt = $this->manualGroupModel->selectListData($where);
        return $ruslt;
    }
    /**
     * @获取一级分类
     */
    public function getParentList(){
        //,['ManualGroupModel.pid','=',$pid]
        $ruslt = $this->manualGroupModel->selectParentList();
        return $ruslt;
    }
    
    /**
     * @param $key
     * @param array $data
     * @return mixed
     */
    protected function _getResponse($key, $data = [])
    {
        $maps = [
            "SUCCESS" => ["status" => 0, "msg" => "sccuess", "data" => $data],
            "USER_ADD" => ["status" => 0, "msg" => "添加成功", "data" => $data],
            "ENBES_DATE" => ["status" => 0, "msg" => "操作成功", "data" => $data],
            "DELETE_DATE" => ["status" => 0, "msg" => "删除成功", "data" => $data],
            "PARAM_EORRE" => ["status" => 1, "msg" => "参数错误", "data" => $data],
            "NUKNOW_EORRE" => ["status" => 2, "msg" => "未知错误", "data" => $data],
            "AUTH_EORRE" => ["status" => 3, "msg" => "权限不足", "data" => $data],
            "NO_POST" => ["status" => 4, "msg" => "非法请求", "data" => $data],
            "USER_ERROR" => ["status" => 5, "msg" => "用户名已存在", "data" => $data],
            "CAOZUO_ERROR" => ["status" => 6, "msg" => "操作失败", "data" => $data],
            "ROLE_ERROR" => ["status" => 7, "msg" => "该角色已经存在", "data" => $data]
        ];
        return $maps[$key];
    }
}